A Top N Report displays details for the top results in your report. You can create this report by modifying the SQL query while creating a dataset.
The following steps demonstrate how to create a Top N report. These steps assume that you have already added a Page Report template to your project and connected it to a data source. See Adding an ActiveReport to a Project and Connect to a Data Source for more information.
- In the Report Explorer, right-click the data source node (DataSource1 by default) and select the Add Data Set option or select Data Set from the add button.
- In the DataSet dialog that appears, go to the Query page and enter a query in the Query textbox in the following format :
Select Top N FieldNames From TableName
Note: In the query above TableName refers to the table you want to get from the database. FieldNames and N refer to the fields you want to fetch from the table and the number of records to display from that field. Following is an example of a Top N Report SQL query : Select Top 10 * From Movie
- Click the Validate DataSet icon at the top right hand corner above the Query box to validate the query and then click OK to close the dialog.
- In the Report Explorer, expand the DataSet node and drag and drop fields onto the design surface. In an FPL report, you need to place these fields inside a data region.
- Go to the Preview tab and view the result. You'll notice only N number of records displaying in your report.
The following image is an example of a Top N Report displaying top 10 movie records: